New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@tiptap/extension-bubble-menu

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiptap/extension-bubble-menu

bubble-menu extension for tiptap


Version published
Maintainers
6
Created
Issues
547

What is @tiptap/extension-bubble-menu?

@tiptap/extension-bubble-menu is an extension for the Tiptap editor that provides a contextual menu (bubble menu) that appears when you select text. This menu can be customized to include various formatting options and actions, making it a powerful tool for enhancing the user experience in rich text editing.

What are @tiptap/extension-bubble-menu's main functionalities?

Basic Bubble Menu

This code sets up a basic bubble menu that appears when text is selected. The menu is linked to a DOM element with the class 'bubble-menu'.

import { BubbleMenu } from '@tiptap/extension-bubble-menu';
import { Editor } from '@tiptap/core';
import StarterKit from '@tiptap/starter-kit';

const editor = new Editor({
  extensions: [
    StarterKit,
    BubbleMenu.configure({
      element: document.querySelector('.bubble-menu'),
    }),
  ],
});

Custom Bubble Menu

This code configures a custom bubble menu with additional Tippy.js options, such as setting the duration of the menu's appearance animation.

import { BubbleMenu } from '@tiptap/extension-bubble-menu';
import { Editor } from '@tiptap/core';
import StarterKit from '@tiptap/starter-kit';

const editor = new Editor({
  extensions: [
    StarterKit,
    BubbleMenu.configure({
      element: document.querySelector('.custom-bubble-menu'),
      tippyOptions: {
        duration: 100,
      },
    }),
  ],
});

Conditional Bubble Menu

This code sets up a bubble menu that only appears when there is a text selection (i.e., the selection is not empty).

import { BubbleMenu } from '@tiptap/extension-bubble-menu';
import { Editor } from '@tiptap/core';
import StarterKit from '@tiptap/starter-kit';

const editor = new Editor({
  extensions: [
    StarterKit,
    BubbleMenu.configure({
      element: document.querySelector('.conditional-bubble-menu'),
      shouldShow: ({ state }) => {
        return state.selection.empty === false;
      },
    }),
  ],
});

Other packages similar to @tiptap/extension-bubble-menu

FAQs

Package last updated on 31 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts